package com.xzy.generic.bad.example.a;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

/**
 * {@link AaaEvent} 事件发布器
 *
 * @author xzy.xiao
 * @date 2022/10/8  19:09
 */
public class AaaEventPublisher {
    private static final Logger logger = LoggerFactory.getLogger(AaaEventPublisher.class);

    public static void sendInsertEvent(ApplicationContext applicationContext) {
        AaaEvent aaaEvent = new AaaEvent(AaaEventPublisher.class, OperationType.INSERT, new AaaData());
        logger.info("发布事件：{}", aaaEvent);
        applicationContext.publishEvent(aaaEvent);
    }

    public static void sendDeleteEvent(ApplicationContext applicationContext) {
        AaaEvent aaaEvent = new AaaEvent(AaaEventPublisher.class, OperationType.DELETE, new AaaData());
        logger.info("发布事件：{}", aaaEvent);
        applicationContext.publishEvent(aaaEvent);
    }

    public static void sendUpdateEvent(ApplicationContext applicationContext) {
        AaaEvent aaaEvent = new AaaEvent(AaaEventPublisher.class, OperationType.UPDATE, new AaaData());
        logger.info("发布事件：{}", aaaEvent);
        applicationContext.publishEvent(aaaEvent);
    }
}
